package com.bocai.kelala.ui.travel.stroke.ada;

import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bocai.kelala.R;
import com.bocai.kelala.bean.MyGradOrderBean;
import com.bocai.mybase.base.BaseRecyclerAdapter;
import com.bocai.mybase.base.BaseRecyclerViewHolder;
import com.bumptech.glide.Glide;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by yuanfei on 2017/6/13.
 */

public class MyReserveStrokeAda extends BaseRecyclerAdapter<MyGradOrderBean.OrderListBean> {


    @Override
    public void showData(BaseRecyclerViewHolder viewHolder, int i, List<MyGradOrderBean.OrderListBean> mItemDataList) {
        MyViewHolder myViewHolder = (MyViewHolder) viewHolder;
        myViewHolder.itemDate.setText("发布时间："+mItemDataList.get(i).getCreateTime());
        myViewHolder.itemEndAddress.setText(mItemDataList.get(i).getArriveCity().replace("市",""));
        myViewHolder.itemStartAddress.setText(mItemDataList.get(i).getOriginCity().replace("市",""));
        myViewHolder.tvStartDate.setText(mItemDataList.get(i).getBeginTime()+" - "+mItemDataList.get(i).getEndTime());
        myViewHolder.tvType.setText("我预约的行程");
        if (mItemDataList.get(i).getOrderStatus() == 1){
            myViewHolder.itemStrokeType.setText("待付款");
            myViewHolder.itemStrokeType.setTextColor(Color.parseColor("#DB544D"));
            Glide.with(mContext).load(R.mipmap.daifukuan).into(myViewHolder.imgType);
        }else if (mItemDataList.get(i).getOrderStatus() == 2){
            myViewHolder.itemStrokeType.setText("待出发");
            myViewHolder.itemStrokeType.setTextColor(Color.parseColor("#57B96D"));
            Glide.with(mContext).load(R.mipmap.daichuf).into(myViewHolder.imgType);
        }else if (mItemDataList.get(i).getOrderStatus() == 5){
            myViewHolder.itemStrokeType.setText("行程中");
            myViewHolder.itemStrokeType.setTextColor(Color.parseColor("#4AB4FF"));
            Glide.with(mContext).load(R.mipmap.xingshi).into(myViewHolder.imgType);
        }else if (mItemDataList.get(i).getOrderStatus() == 3){
            myViewHolder.itemStrokeType.setText("已完成");
            myViewHolder.itemStrokeType.setTextColor(Color.parseColor("#24B3FA"));
            Glide.with(mContext).load(R.mipmap.order_complete).into(myViewHolder.imgType);
        }else if (mItemDataList.get(i).getOrderStatus() == 6){
            myViewHolder.itemStrokeType.setText("地址修改待确认");
            myViewHolder.itemStrokeType.setTextColor(Color.parseColor("#24B3FA"));
            Glide.with(mContext).load(R.mipmap.order_complete).into(myViewHolder.imgType);
        }else if (mItemDataList.get(i).getOrderStatus() == 7){
            myViewHolder.itemStrokeType.setText("地址修改已确认");
            myViewHolder.itemStrokeType.setTextColor(Color.parseColor("#24B3FA"));
            Glide.with(mContext).load(R.mipmap.order_complete).into(myViewHolder.imgType);
        }

    }

    @Override
    public int getListLayoutId() {
        return R.layout.item_my_publish_stroke;
    }

    @Override
    public RecyclerView.ViewHolder createViewHolder(View view) {
        return new MyViewHolder(view);
    }

    class MyViewHolder extends BaseRecyclerViewHolder {
        @BindView(R.id.item_stroke_type)
        TextView itemStrokeType;
        @BindView(R.id.tv_start_date)
        TextView tvStartDate;
        @BindView(R.id.item_start_address)
        TextView itemStartAddress;
        @BindView(R.id.item_end_address)
        TextView itemEndAddress;
        @BindView(R.id.item_date)
        TextView itemDate;
        @BindView(R.id.img_type)
        ImageView imgType;
        @BindView(R.id.tv_type)
        TextView tvType;
        public MyViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
